//
//  InputMessageViewController.m
//  HappyBug
//
//  Created by liulei on 2018/11/6.
//  Copyright © 2018年 www.hc.com.cn. All rights reserved.
//

#import "InputMessageViewController.h"
#define  WHITH   [UIScreen mainScreen].bounds.size.width
#define  HEIGHT  [UIScreen mainScreen].bounds.size.height
@interface InputMessageViewController ()

@end

@implementation InputMessageViewController{
    UITextField *fileldTxt;
}

-(void)backmain{
    NSString *inputTXT=fileldTxt.text;
    [[NSUserDefaults standardUserDefaults] setObject:inputTXT  forKey:@"TXTVALUE"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor whiteColor]];


    UIImage *lrightimage=[UIImage imageNamed:@"tabbar_icon_found_normal"];
    UIButton *button2 =[[UIButton alloc]init];
    [button2 addTarget:self action:@selector(backmain) forControlEvents:UIControlEventTouchUpInside];
    [button2 setBackgroundImage:lrightimage forState:UIControlStateNormal];
    UIBarButtonItem *item2 =[[UIBarButtonItem alloc]initWithCustomView:button2];
    self.navigationItem.title=@"个人信息修改";
    //只能设置items
    self.navigationItem.leftBarButtonItem=item2;
    
    CGRect rectOfStatusbar = [[UIApplication sharedApplication] statusBarFrame];
    NSUInteger hei =  self.navigationController.navigationBar.frame.size.height;
    
    //第一个输入内容
    UIView  *txtLineView= [[UIView alloc]init];
    txtLineView.layer.cornerRadius=3;
    txtLineView.layer.backgroundColor=[UIColor grayColor].CGColor;
    txtLineView.frame=CGRectMake(0,hei+rectOfStatusbar.size.height+2, WHITH, 50);
    txtLineView.backgroundColor=[UIColor whiteColor];
    txtLineView.userInteractionEnabled=YES;
    [self.view addSubview:txtLineView];
    
    
    UIView *line =[[UIView alloc]initWithFrame:CGRectMake(0, txtLineView.frame.origin.y+txtLineView.frame.size.height, WHITH, 0.5)];
    [line setBackgroundColor:[UIColor grayColor]];
    [self.view addSubview:line];
    
    UILabel *label1 =[[UILabel alloc]init];
    label1.frame=CGRectMake(10,0, 100, 50);
    label1.textAlignment=NSTextAlignmentLeft;
    label1.text=@"姓名";
    label1.font=[UIFont systemFontOfSize:18];
    [txtLineView addSubview:label1];
    
    NSString *inputTXT=  [[NSUserDefaults standardUserDefaults] objectForKey:@"TXTVALUE"];
    fileldTxt=[[UITextField alloc]init];
    fileldTxt.frame=CGRectMake(label1.frame.size.width+label1.frame.origin.x-5,0, 100, 50);
    fileldTxt.font=[UIFont systemFontOfSize:16];
    fileldTxt.keyboardType=UIKeyboardTypeDefault;
    fileldTxt.text=inputTXT;
    [fileldTxt becomeFirstResponder];
    [txtLineView addSubview:fileldTxt];
    
    UIImage *image=[UIImage imageNamed:@"nextpng"];
    UIImageView *imageView=[[UIImageView alloc]init];
    imageView.image=image;
    //如果高度不一样 用外面的-里面的高度除以2
    imageView.frame=CGRectMake(WHITH-40,(txtLineView.frame.size.height-30)/2, 20, 20);
    [txtLineView addSubview:imageView];
    
    [self.view addSubview:txtLineView];
    
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    NSString *inputTXT=fileldTxt.text;
    [[NSUserDefaults standardUserDefaults] setObject:inputTXT  forKey:@"TXTVALUE"];
    [[NSUserDefaults standardUserDefaults] synchronize];

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
